package ms.core.common;

import java.util.List;

import lombok.Data;

@Data
public class Page<T> {
	private int page = 1;
	private int pages = -1;
	private int pageSize = 20;
	private long rows;
	private List<T> data;

	public Page<T> setPageInfo(int page, int pageSize, int pages, long rows, List<T> data) {
		this.page 	  = page;
		this.pageSize = pageSize;
		this.pages 	  = pages;
		this.rows 	  = rows;
		this.data 	  = data;
		return this;
	}

	public int getPages() { 
		if (pages!=-1) return pages;
		return Math.round((rows+pageSize-1) / pageSize); 
	}
}
